<?php
// 接收前端参数把数据插入数据库

$name = $_GET['name'];
$password = $_GET['password'];


$conn = mysqli_connect('localhost', 'root', '123456', 'h52008');
mysqli_query($conn, "set charset 'utf8'");
mysqli_query($conn, "set character set 'utf8'");

$sql = "insert into user (name,pwd) values ('$name',$password)";
$res = mysqli_query($conn, $sql);

if ($res) {
  echo json_encode(array(
    "code" => 200,
    "body" => array(
      "msg" => "添加成功"
    )
  ));
} else {
  echo json_encode(array(
    "code" => 201,
    "body" => array(
      "msg" => "登录失败请重试"
    )
  ));
}

?>